<template>
	<view class="user-agreement-content">
		<view v-if="fromUseSence === 'infiniteRewardSence'" style="font-size: 26rpx; line-height: 26rpx;color: #FFFFFF;margin-bottom: 20rpx;">
			<view class="flex items-center" @click="isSwitchChange">
				<image 
					v-show="!isRewardAniamteSwitch" 
					src="/static/images/public_imgs/select.png" 
					style="width: 28rpx; height: 28rpx" mode=""> </image>
					
				<image 
					v-show="isRewardAniamteSwitch" 
					src="/static/images/public_imgs/selecting.png" 
					style="width: 28rpx; height: 28rpx" mode=""> </image>
					
				<view class="" style="margin-left: 12rpx;"> 跳过大赏动画(内存较小的机型建议勾选) </view>
			</view>		
		</view>
		
		<view style="font-size: 26rpx; line-height: 26rpx;color: #FFFFFF">
			<view class="flex items-center" @click="isAcceptAgreement = !isAcceptAgreement">
				<image 
					v-show="!isAcceptAgreement" 
					src="/static/images/public_imgs/select.png" 
					style="width: 28rpx; height: 28rpx" mode=""> </image>
					
				<image 
					v-show="isAcceptAgreement" 
					src="/static/images/public_imgs/selecting.png" 
					style="width: 28rpx; height: 28rpx" mode=""> </image>
					
				<view class="" style="margin-left: 12rpx;"> 本人已满18周岁且具备完全行为能力，充值即代表同意 </view>
			</view>
		
			<view style="margin-left: 30rpx; margin-top: 12rpx;color: #63FFF7;" @click.stop="agreementFun">《购买协议》&《隐私条款》</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'comUserAgreement',
		props: {
			isShowOrderAgreeUppop: Number,
			value: Boolean | Number,
			// 使用场景类型: infiniteRewardSence 飞机赏抽赏场景
			fromUseSence: {
				type: String,
				default: () => ''
			},
		},
		data() {
			return {
				isAcceptAgreement: false,
				isRewardAniamteSwitch: uni.getStorageSync('isRewardAniamteSwitch'),
			};
		},
		computed: {
			userInfo() {
				return this.$store.getters.userInfo;
			},
		},
		watch: {
			isShowOrderAgreeUppop: {
				handler() {
					if (!uni.getStorageSync('isAcceptAgreement')) {
						return;
					}
					this.isAcceptAgreement = this.isShowOrderAgreeUppop;
				},
				immediate: true,
				deep: true
			},
			
			isAcceptAgreement: {
				handler(newValue) {
					this.$emit('input', newValue);
					uni.setStorage({
						key: 'isAcceptAgreement',
						data: newValue
					});
				},
				immediate: true,
				deep: true
			},
		},
		methods: {
			agreementFun() {
				this.$store.commit('SHOW_AGREEMENT_SET_FUN', true);
			},
			isSwitchChange() {
				this.isRewardAniamteSwitch = !this.isRewardAniamteSwitch;
				return uni.setStorageSync('isRewardAniamteSwitch', this.isRewardAniamteSwitch);
			},
		}
	};
</script>

<style lang="scss"></style>
